from pymysql import Connection

conn = None

try:
    conn = Connection(host='linux2.server', port=3306, user='root', password='Chenhao$123456')
    print(type(conn))
    print(conn.get_host_info())
    print(conn.get_server_info())
except Exception as e:
    print("发生异常：", e)
finally:
    if conn:
        conn.close()
